home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / Developer Essentials Jul 90 / Apple II / Programming & Utilities / Apple IIgs APW Intro Prog Src / HP.ASM / DIALOG.ASM.txt next >
Encoding:
Text File  |  1987-08-31  |  15.7 KB  |  490 lines

  1.  
  2. ******************************************************************************
  3. *                                                                            *
  4. *         HodgePodge:  An example Apple IIGS Desktop application             *
  5. *                                                                            *
  6. *         Written in 65816 Assembler by the Apple IIGS Tools Team            *
  7. *  Modified by Ben Koning for "Programmer's Introduction to the Apple IIGS"  *
  8. *                                                                            *
  9. *             Copyright (c) 1986-87 by Apple Computer, Inc.                  *
  10. *                                                                            *
  11. *   ----------------------------------------------------------------------   *
  12. *                                                                            *
  13. *   ASM65816 Code file "DIALOG.ASM" -- Various dialogs taking modal control  *
  14. *                                                                            *
  15. ******************************************************************************
  16.  
  17.  
  18.  
  19. ****************************************************************
  20. *
  21. * ManyWindDialog -- Warning that too many windows are open.
  22. *
  23. ****************************************************************
  24.  
  25. ManyWindDialog START
  26.                using GlobalData
  27.  
  28.                pha
  29.                pushlong #OurAlert
  30.                pushlong #$0000
  31.                _CautionAlert
  32.                pla                      ; get the item hit
  33.                rts
  34.  
  35. OurAlert       dc i'30,120,80,520'      ; bounds rect
  36.                dc i'2374'               ; id
  37.                dc h'80'
  38.                dc h'80'
  39.                dc h'80'
  40.                dc h'80'
  41.                dc i4'item1'
  42.                dc i4'item2'
  43.                dc i4'0000'
  44.  
  45. item1          dc i2'1'                 ; id
  46.                dc i2'25,320,00,00'      ; bounds rect for button
  47.                dc i2'ButtonItem'        ; type
  48.                dc i4'But1'              ; item descreptor
  49.                dc i2'00'                ; item value
  50.                dc i2'0'                 ; item flag
  51.                dc i4'0'                 ; item color
  52.  
  53. item2          dc i2'1348'              ; id
  54.                dc i2'11,72,200,640'     ; bounds rect for message
  55.                dc i2'StatText+$8000'    ; type + disabled
  56.                dc i4'Msg'               ; item descreptor
  57.                dc i2'00'                ; item value
  58.                dc i2'0'                 ; item flag
  59.                dc i4'0'                 ; item color
  60.  
  61. But1           str 'OK'
  62. Msg            str 'No more windows, please.'
  63.  
  64.                end
  65.  
  66.  
  67.  
  68. ****************************************************************
  69. *
  70. * DoAboutItem
  71. *
  72. * Brings up about box and waits until button press until
  73. * it puts it away. Shows how to build a dialog window by hand.
  74. *
  75. ****************************************************************
  76.  
  77. DoAboutItem    START
  78.                using globalData
  79.  
  80.                PushLong #0              ; get space for Icon
  81.                PushLong #34*16+8        ; #lines * bytes/line + rect
  82.                PushWord MyId
  83.                PushWord #0              ; don't care where it goes
  84.                PushLong #0
  85.                _NewHandle
  86.                pla
  87.                plx
  88.                bcc ok
  89.                lda #$81                 ; out of memory
  90.                ldx #1
  91.                jmp CheckDiskError       ; Go and tell user error message,
  92. ;                                       ; and use its RTS to exit from here.
  93.  
  94. ok             anop
  95.                sta AppleIconH
  96.                stx AppleIconH+2
  97.  
  98.                jsr deref
  99.  
  100.                sta 0
  101.                stx 2
  102.  
  103.                ldy #0                   ;move Icon to new space
  104. Copy640        lda AppleIcon640,y
  105.                sta [0],y
  106.                iny
  107.                iny
  108.                cpy #34*16+8
  109.                bne Copy640
  110.  
  111. FixDBox        ldx #160+10
  112.                lda #640-160-10
  113.  
  114. JoinRect       stx DRect+2
  115.                sta DRect+6
  116.  
  117.                PushLong #0              ; output
  118.                PushLong #DRect
  119.                PushWord #True           ; visible
  120.                PushLong #0              ; refcon
  121.                _NewModalDialog
  122.  
  123.                pla
  124.                sta MDialogPtr
  125.                pla
  126.                sta MDialogPtr+2
  127.  
  128.                PushLong MDialogPtr
  129.                PushWord #1
  130.                PushLong #ButtonRect
  131.                PushWord #ButtonItem
  132.                PushLong #ButtonText
  133.                PushWord #0
  134.                PushWord #0
  135.                PushLong #0
  136.                _NewDItem
  137.  
  138.                PushLong MDialogPtr
  139.                PushWord #2
  140.                PushLong #AppleIconRect
  141.                PushWord #IconItem+ItemDisable
  142.                PushLong AppleIconH
  143.                PushWord #0
  144.                PushWord #0
  145.                PushLong #0
  146.                _NewDItem
  147.  
  148.                PushLong MDialogPtr
  149.                PushWord #4
  150.                PushLong #TextRect
  151.                PushWord #LongStatText2+ItemDisable
  152.                PushLong #StartOfText
  153.                PushWord #EndOfText-StartOfText
  154.                PushWord #0
  155.                PushLong #0
  156.                _NewDItem
  157.  
  158. DoModal        PushWord #0              ; result
  159.                PushLong #0              ; no filterproc
  160.                _ModalDialog
  161.                pla                      ; chuck the item hit
  162.  
  163.                PushLong MDialogPtr
  164.                _CloseDialog
  165.  
  166.                PushLong AppleIconH
  167.                _DisposeHandle
  168.  
  169.                rts
  170.  
  171. DRect          dc i'20,10,192,320-10'
  172.  
  173. AppleIconH     ds 4
  174. AppleIconRect  dc i'135,20,0,0'
  175.  
  176. AppleIcon640   anop
  177.                dc i'0,0,34,64'
  178.                dc  h'00000000000000000000000000000000'
  179.                DC  h'0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0'
  180.                DC  h'0F0000000000000000000000000000F0'
  181.                DC  h'0F0FFFFFFFFFFFFFFFFFFFFFFFFFF0F0'
  182.                DC  h'0F0FFFFFFFFFFFFFFFFFF88FFFFFF0F0'
  183.                DC  h'0F0FFFFFFFFFFFFFFFF8888FFFFFF0F0'
  184.                DC  h'0F0FFFFFFFFFFFFFFF88888FFFFFF0F0'
  185.                DC  h'0F0FFFFFFFFFFFFFF88888FFFFFFF0F0'
  186.                DC  h'0F0FFFFFFFFFFFFF888888FFFFFFF0F0'
  187.                DC  h'0F0FFFFFFFFFFFFF88888FFFFFFFF0F0'
  188.                DC  h'0F0FFFFFFFFFFFFF8888FFFFFFFFF0F0'
  189.                DC  h'0F0FFFFFF8888FFF88FF8888FFFFF0F0'
  190.                DC  h'0F0FFFF88888888FFF88888888FFF0F0'
  191.                DC  h'0F0FFF888888888888888888888FF0F0'
  192.                DC  h'0F0FFeeeeeeeeeeeeeeeeeeeeFFFF0F0'
  193.                DC  h'0F0FFeeeeeeeeeeeeeeeeeeeFFFFF0F0'
  194.                DC  h'0F0FFeeeeeeeeeeeeeeeeeeFFFFFF0F0'
  195.                DC  h'0F0FF666666666666666666FFFFFF0F0'
  196.                DC  h'0F0FF666666666666666666FFFFFF0F0'
  197.                DC  h'0F0FF666666666666666666FFFFFF0F0'
  198.                DC  h'0F0FF4444444444444444444FFFFF0F0'
  199.                DC  h'0F0FF44444444444444444444FFFF0F0'
  200.                DC  h'0F0FFF444444444444444444444FF0F0'
  201.                DC  h'0F0FFF555555555555555555555FF0F0'
  202.                DC  h'0F0FFF555555555555555555555FF0F0'
  203.                DC  h'0F0FFFF5555555555555555555FFF0F0'
  204.                DC  h'0F0FFFF1111111111111111111FFF0F0'
  205.                DC  h'0F0FFFFF11111111111111111FFFF0F0'
  206.                DC  h'0F0FFFFFF111111FFF111111FFFFF0F0'
  207.                DC  h'0F0FFFFFFF1111FFFFF1111FFFFFF0F0'
  208.                DC  h'0F0FFFFFFFFFFFFFFFFFFFFFFFFFF0F0'
  209.                DC  h'0F0000000000000000000000000000F0'
  210.                DC  h'0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0'
  211.                DC  h'00000000000000000000000000000000'
  212.  
  213. TextRect       dc i2'4,10,135,280'
  214. StartOfText    anop
  215.                dc h'01',c'J',i'1'           ; center 
  216.                dc h'01',c'S',i'$0008'       ; Outline
  217.                dc c'HodgePodge',h'0D'
  218.                dc h'01',c'S',i'$0000'       ; plain
  219.                dc c'A potpourri of routines that '
  220.                dc c'demonstrate many features of '
  221.                dc c'the Apple IIGS Tools.'
  222.                dc h'0D'
  223.                dc h'0D'
  224.                dc c'By Ben Koning and the Apple IIGS '
  225.                dc c'Tools Group:'
  226.                dc h'0D'
  227.                dc c'Eagle I. Berns, Art Cabral, Cheryl Ewy, '
  228.                dc c'Steven Glass, Suki Lee, '
  229.                dc c'Pete McDonald, Bennet Marks, Dan Oliver, '
  230.                dc c'Dan Hitchens, and Keith Rollin.'
  231.                dc h'0D'
  232.                dc c'Copyright Apple Computer, Inc., '
  233.                dc c'1986-87, All Rights Reserved',h'0D'
  234.                dc c'v1.0  '
  235.                dc c'&SysDate'
  236. EndOfText      anop
  237.  
  238. ButtonRect     dc i'153,205,0,0'
  239.  
  240. ButtonText     str 'OK'
  241.  
  242. MDialogPtr     ds 4
  243.  
  244.                END
  245.  
  246.  
  247.  
  248. ****************************************************************
  249. *
  250. * ShowPleaseWait / HidePleaseWait
  251. *
  252. * Brings up a window and immediately puts message in it
  253. * (without waiting for update event).
  254. *
  255. ****************************************************************
  256.  
  257. ShowPleaseWait START
  258.                using globalData
  259.  
  260.                PushLong #0              ; save the current port
  261.                _GetPort
  262.  
  263.                pla
  264.                sta OrigPort
  265.                pla
  266.                sta OrigPort+2
  267.  
  268.                PushLong #0
  269.                PushLong #DialogTemplate
  270.                _GetNewModalDialog
  271.  
  272.                pla
  273.                sta MsgWinPtr
  274.                pla
  275.                sta MsgWinPtr+2
  276.  
  277.                PushLong MsgWinPtr       ; begin the updating process
  278.                _BeginUpdate
  279.  
  280.                PushLong MsgWinPtr
  281.                _DrawDialog
  282.  
  283.                PushLong MsgWinPtr
  284.                _EndUpdate
  285.  
  286.                rts
  287.  
  288. HidePleaseWait ENTRY
  289.                PushLong MsgWinPtr       ; hide the window
  290.                _CloseDialog
  291.  
  292.                PushLong OrigPort        ; restore the port
  293.                _SetPort
  294.  
  295.                rts
  296.  
  297. MsgWinPtr      ds 4
  298.  
  299. DialogTemplate anop
  300.                dc i'30,120,80,520'      ; bounding box
  301.                dc i'True'               ; visible
  302.                dc i4'0'                 ; refcon
  303.                dc i4'item1'
  304.                dc i4'0000'
  305.  
  306. item1          anop
  307.                dc i2'1348'              ; id
  308.                dc i2'19,70,200,640'     ; bounds rect for text
  309.                dc i2'StatText'          ; type
  310.                dc i4'Msg'               ; item descreptor
  311.                dc i2'00'                ; item value
  312.                dc i2'0'                 ; item flag
  313.                dc i4'0'                 ; item color
  314.  
  315. Msg            str 'Please wait while we set things up.'
  316.  
  317.                END
  318.  
  319.  
  320.  
  321. ****************************************************************
  322. *
  323. * MountBootDisk
  324. *
  325. * This is a routine that is called whenever the application
  326. * needs to get something off the boot volume and the
  327. * boot volume is not on line.
  328. *
  329. * This can occur when loading fonts, tools or drivers.
  330. *
  331. ****************************************************************
  332.  
  333. MountBootDisk  START
  334.  
  335.                _Set_Prefix SetPrefixParams
  336.                _Get_Prefix GetPrefixParams
  337.  
  338.                PushWord #0              ;Space for result
  339.                PushWord #174            ;x pos
  340.                PushWord #30             ;y pos
  341.                PushLong #PromptStr      ;Prompt string
  342.                PushLong #VolStr         ;Vol string
  343.                PushLong #OKStr
  344.                PushLong #CancelStr
  345.                _TLMountVolume
  346.  
  347.                pla
  348.  
  349.                rts
  350.  
  351. PromptStr      str 'Please insert the disk'
  352. OKStr          str 'OK'
  353. CancelStr      str 'Shutdown'
  354.  
  355. GetPrefixParams dc i'7'
  356.                dc i4'VolStr'
  357.  
  358. SetPrefixParams dc i'7'
  359.                dc i4'BootStr'
  360.  
  361. VolStr         ds 16
  362.  
  363. BootStr        str '*/'
  364.  
  365.                END
  366.  
  367.  
  368.  
  369. ****************************************************************
  370. *
  371. * CheckToolError
  372. *
  373. * Cause system death if A register is nonzero and carry set;
  374. * otherwise, it just returns.
  375. *
  376. * Error code to make part of string is in A register.
  377. * "Where" number to make part of string is in X register.
  378. *
  379. ****************************************************************
  380.  
  381. CheckToolError START
  382.  
  383.                bcs RealDeath            ;If a tool error didn't happen
  384.                rts                      ;then just return
  385.  
  386. RealDeath      pha                      ;Save error code for now
  387.  
  388.                pea 0                    ;Convert the "Where" debug trace
  389.                pea 0                    ;number to a four-digit ASCII hex
  390.                phx                      ;string.
  391.                _Hexit
  392.                pla
  393.                sta codes
  394.                pla
  395.                sta codes+2
  396.  
  397.                pla                      ;Restore error code
  398.  
  399.                pha                      ;Exit to system failure handler
  400.                PushLong #DeathMsg       ;(bouncing apple)
  401.                _SysFailMgr
  402.  
  403. DeathMsg       anop
  404.                dc i1'EndMsg-StartMsg'
  405. StartMsg       dc c' At $'
  406. Codes          ds 4
  407.                dc c'; Could not handle error $'
  408. EndMsg         anop
  409.  
  410.                END
  411.  
  412.  
  413.  
  414. ****************************************************************
  415. *
  416. * CheckDiskError -- Display stop alert dialog if ProDOS error happened.
  417. *                   We sniff the A register to see if an error occurred,
  418. *                   and assume the X register to be loaded with a
  419. *                   "where" value, used to locate bugs.
  420. *
  421. ****************************************************************
  422.  
  423. CheckDiskError START
  424.                using GlobalData
  425.  
  426.                phx                      ; Save the Where value
  427.                pha                      ; Save the error number
  428.  
  429.                _InitCursor              ; Set pointer--looks better than watch
  430.  
  431.                pla                      ; Restore the error number
  432.                pha                      ; Convert the error message
  433.                PushLong #OurErrStr      ; to an ASCII string 4 chars long
  434.                PushWord #4
  435.                _Int2Hex
  436.  
  437.                pla                      ; Do this just for clarity (note that
  438.                pha                      ; Where value is already on stack!)
  439.                PushLong #OurWhereStr    ; Convert the Where value
  440.                PushWord #2              ; to an ASCII string 2 chars long
  441.                _Int2Hex
  442.  
  443.                pha                      ; Space for result
  444.                pushlong #OurAlert       ; Pointer to template
  445.                pushlong #$0000          ; Standard Filter procedure
  446.                _StopAlert               ; Draw box and wait for mouse OK press
  447.                pla                      ; Get the item hit (the OK button)
  448.  
  449.                sec                      ; Set the error flag
  450.                rts                      ; Return to caller
  451.  
  452. OurAlert       dc i'30,120,80,520'      ; bounds rect
  453.                dc i'6666'               ; id
  454.                dc h'80'
  455.                dc h'80'
  456.                dc h'80'
  457.                dc h'80'
  458.                dc i4'OKButton'
  459.                dc i4'Message'
  460.                dc i4'0000'
  461.  
  462. OKButton       dc i2'1'                 ; id
  463.                dc i2'25,320,00,00'      ; bounds rect for button
  464.                dc i2'ButtonItem'        ; type
  465.                dc i4'OKName'            ; item descreptor
  466.                dc i2'00'                ; item value
  467.                dc i2'0'                 ; item flag
  468.                dc i4'0'                 ; item color
  469.  
  470. Message        dc i2'1348'              ; id
  471.                dc i2'11,72,200,640'     ; bounds rect for static text
  472.                dc i2'StatText+$8000'    ; type + disable flag
  473. ErrMsgPtr      dc i4'Msg'               ; item descreptor
  474.                dc i2'00'                ; item value
  475.                dc i2'0'                 ; item flag
  476.                dc i4'0'                 ; item color
  477.  
  478. OKName         str 'OK'
  479.  
  480. Msg            dc i1'EndMsg-StartMsg'
  481. StartMsg       dc c'Disk error $'
  482. OurErrStr      ds 4
  483.                dc c' occurred at $'
  484. OurWhereStr    ds 2
  485.                dc c'.'
  486.                dc h'0D'
  487. EndMsg         anop
  488.  
  489.                END
  490.